/********************************************************************************
*																				*
*  Las Venturas Playground - Core/mysql.nut										*
*																				*
*  The MySQL class of the gamemode comes here.									*
*																				*
*********************************************************************************/

class MySQL
{
	// These variables will hold the MySQL details.
	sServer = "";
	sUser = "";
	sPassword = "";
	sDatabase = "";
	
	// This holds the connection.
	connectionHandle = false;
	
	/**
	 * This is the constructor of the MySQL class, it
	 * sets the MySQL details when called.
	 *
	 * @param Server The server to connect to.
	 * @param User The user to login with.
	 * @param Password The password to login with.
	 * @param Database The database to select upon connection.
	 * @returns void
	 */
	
	constructor( Server, User, Password, Database )
	{
		this.sServer = Server;
		this.sUser = User;
		this.sPassword = sPassword;
		this.sDatabase = Database;
	}
	
	/**
	 * This function connects to the MySQL with the specified details.
	 *
	 * @returns void
	 */
	
	function Connect()
	{
		// Create the connection with the server.
		connectionHandle = mysql_connect( sServer, sUser, sPassword, sDatabase );
	}
	
	/**
	 * This function checks whether the gameserver is connected to the MySQL database.
	 *
	 * @returns boolean true if the connect attempt was succesful, false otherwise.
	 */
	 
	function isConnected()
	{
		if(!connectionHandle || !mysql_ping(connectionHandle)) return false;
		return true;
	}
}